<HTML><HEAD><TITLE>read_string(+Delimiters, ?Length, -String)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Character I/O</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>read_string(+Delimiters, ?Length, -String)</H1>
Reads a string from the input stream up to a delimiter or up to a specified length
<DL>
<DT><EM>Delimiters</EM></DT>
<DD>String or atom.
</DD>
<DT><EM>Length</EM></DT>
<DD>Integer or variable.
</DD>
<DT><EM>String</EM></DT>
<DD>String or variable.
</DD>
</DL>
<H2>Description</H2>
   A string of characters is read from the input up to one character which
   occurs in the delimiter string Delimiters.  This character is also
   consumed, but does not appear in the string which is unified with
   String.
   
   Two symbolic Delimiters can be specified:

<P>
<PRE>
    end_of_line   a newline or carriage-return/newline sequence
    end_of_file   the end of the file/input
</PRE>
   End of file always acts like a delimiter.

<P>
   If Length is a variable, it is unified with the length of the string
   String.  If Length is an integer, the number of characters read from
   the input is limited by the Length.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>read_string(+, +, -) is semidet
<LI>read_string(+, -, -) is semidet
</UL>
<H3>Fail Conditions</H3>
There is nothing to read, i.e. the stream is at end_of_file
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Delimiters is not instantiated.
<DT><EM>(5) type error </EM>
<DD>Delimiters is not a string or atom.
<DT><EM>(5) type error </EM>
<DD>Length is not an atom or an integer.
<DT><EM>(5) type error </EM>
<DD>String is not an atom or a string.
<DT><EM>(6) out of range </EM>
<DD>Delimiters is an atom but not a valid symbolic delimiter.
<DT><EM>(190) end of file reached </EM>
<DD>End of file was encountered before reading any character.
<DT><EM>(198) reading past the file end </EM>
<DD>Trying to read even after the error 190 was raised.
</DL>
<H2>Examples</H2>
<PRE>   Equivalent to read_string(input, Delimiters, Length, String).  (see
   read_string/4 for details).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/iochar/read_string-4.html">read_string / 4</A>, <A HREF="../../kernel/iochar/read_token-2.html">read_token / 2</A>, <A HREF="../../kernel/iochar/read_token-3.html">read_token / 3</A>, <A HREF="../../kernel/iostream/open-3.html">open / 3</A>
</BODY></HTML>
